package interfaces;


import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Login extends JFrame implements ActionListener{

	Welcome welcome = new Welcome();
	
	JLabel nome;
	JLabel senha;
	JTextField textNome;
	JPasswordField textSenha;
	JPanel panel;
	JButton sair;
	JButton ok;
	
	public Login() {
		super("Login");
		this.setSize(400,200);
		this.setLocation(400,150);
		this.setResizable(false);
		this.setVisible(true);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
		
		//inicializa os Labels
		nome = new JLabel("Nome ");
		senha = new JLabel("Senha");
		
		//inicializa os campos de texto
		textNome = new JTextField(30);
		textSenha = new JPasswordField(30);
		
		//inicializa os botoes
		ok = new JButton("OK");
		sair = new JButton("Sair");
		
		//define funcoes para os botoes
		ok.addActionListener(this);
		sair.addActionListener(this);
		
		panel = new JPanel(layout);
		
		panel.add(nome);
		panel.add(textNome);
		panel.add(senha);
		panel.add(textSenha);
		panel.add(ok);
		panel.add(sair);
		
		panel.setSize(400,200);
		panel.setVisible(true);
		this.add(panel);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		Object obj = e.getSource();
		
		if(obj.equals(sair)) {
			this.dispose();
		} else if(obj.equals(ok)) {
			welcome.setVisible(true);
			this.dispose();
		}
		
	}

}
